package com.mku.parkingmanagement_service.service.impl;

import cn.dev33.satoken.util.SaFoxUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mku.parkingmanagement_service.entity.LoginInfo;
import com.mku.parkingmanagement_service.mapper.LoginInfoMapper;
import com.mku.parkingmanagement_service.service.LoginInfoService;
import com.mku.parkingmanagement_service.vo.LoginInfoVo;
import com.mku.parkingmanagement_service.vo.comm.ResultVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @className: LoginInfoServiceImpl
 * @author: Maoxx
 * @date: 2024/11/9 23:04
 * @Version: 1.0
 * @description:
 */

@Service
public class LoginInfoServiceImpl extends ServiceImpl<LoginInfoMapper, LoginInfo> implements LoginInfoService {

    @Resource
    private LoginInfoMapper loginInfoMapper;
    @Override
    public ResultVO<Object> getLoginInfoList(LoginInfoVo loginInfoVo) {
        Page<LoginInfo> page = new Page<>(loginInfoVo.getPagenum(),loginInfoVo.getPageSize());

        //查询条件
        QueryWrapper<LoginInfo> wrapper =new QueryWrapper<>();
        if(!SaFoxUtil.isEmpty(loginInfoVo.getPerson())){
            wrapper.like("person",loginInfoVo.getPerson());
        }
        if(!SaFoxUtil.isEmpty(loginInfoVo.getIp())){
            wrapper.like("ip",loginInfoVo.getIp());
        }

        return ResultVO.success(loginInfoMapper.selectPage(page,wrapper));
    }
}
